package com.zxy.health.service;


import com.zxy.health.dao.HealthCodeDao;
import com.zxy.health.mapper.HealthCodeMapper;
import com.zxy.health.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HealthCodeService {

    @Autowired
    HealthCodeMapper healthCodeMapper;
    @Autowired
    StudentMapper studentMapper;

    public String addHealthReport(HealthCodeDao healthCodeDao){
        if (studentMapper.getStudentBySchoolId(healthCodeDao.getSchoolid()).size()==0){
            return "查无此人，请联系管理员";
        }else {
            studentMapper.updateStudentHealthcode(healthCodeDao.getSchoolid(),healthCodeDao.getHealthcode());
            healthCodeMapper.addHealthReport(healthCodeDao);
            return "true";
        }
    }

    public List<HealthCodeDao> getHealthCodeBySchoolid(String schoolid){
        return healthCodeMapper.getHealthCodeBySchoolId(schoolid);
    }
}
